package com.hbx.residential_service.service.impl;

import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.PayDao;
import com.hbx.residential_service.domain.Pay;
import com.hbx.residential_service.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class PayServiceImpl implements PayService{
    @Autowired
    private PayDao payDao;

    @Override
    public List<Pay> findAll(int page, int size) {
        PageHelper.startPage(page,size);
        return payDao.findAll(page,size);
    }

    @Override
    public void addPay(Pay pay) {
        payDao.addPay(pay);
    }

    @Override
    public void deletePay(int payId) {
        payDao.deletePay(payId);
    }

    @Override
    public Pay findUpdPayById(int payId) {
        return payDao.findUpdPayById(payId);
    }

    @Override
    public void UpdateById(Pay pay) {
        payDao.UpdateById(pay);
    }

    @Override
    public List<Pay> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return payDao.fsByUsername("%"+content+"%",page,size);
    }

    @Override
    public List<Pay> findByUnpaid(int page, int size) {
        PageHelper.startPage(page,size);
        return payDao.findByUnpaid(page,size);
    }
}
